package org.apogee.mil.client.main.pages;

import org.apogee.mil.client.main.MainForm;
import org.apogee.mil.client.widgets.DialogHelper;

import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.VerticalPanel;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.user.client.Element;

public class LogoutForm extends LayoutContainer {
	
	private MainForm mf;

	public LogoutForm(MainForm form) {
		this.mf = form;
	}
	
	@Override
	public void onRender(Element parent, int index) {
		super.onRender(parent, index);
		
		setLayout(new FitLayout());
		setWidth(200);
		setHeight(180);
		
		FormPanel vp = new FormPanel();
		vp.setHeading("Logout");
		vp.setBorders(true);
		vp.setFrame(true);
		
		VerticalPanel hp = new VerticalPanel();
		
		Button b = new Button("Logout");
		b.setStyleAttribute("padding", "10px");
		b.setWidth(150);
		b.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				mf.hideTabs();
				
			}
		});
		
		hp.add(b);
		
		Button a = new Button("Change Password");
		a.setStyleAttribute("padding", "10px");
		a.setWidth(150);
		a.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				DialogHelper helper = new DialogHelper("Change Password", new ChangePwdForm());
				helper.show();
			}
		});
		hp.add(a);
		
		vp.add(hp);
		add(vp);	
	}
}
